package com.qf.test;

import com.baomidou.mybatisplus.core.MybatisSqlSessionFactoryBuilder;
import com.qf.mapper.UserMapper;
import com.qf.pojo.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.junit.Test;

import java.io.InputStream;
import java.util.List;

/**
 * @ClassName test
 * @Author xiao宋
 * @Date 21:37  2022/10/9
 * @Version 1.0
 * @Description TODO
 */
public class test {
    @Test
    public void test1() throws Exception {
        InputStream rs = Resources.getResourceAsStream("mybatis-config.xml");
        SqlSessionFactory sessionFactory = new MybatisSqlSessionFactoryBuilder().build(rs);
//        User user1 = new User();
        SqlSession sqlSession = sessionFactory.openSession();
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        List<User> users = mapper.selectList(null);
        for (User user : users) {
            System.out.println(user.toString());
        }

    }

}
